<?php

class FrontendActions extends sfActions
{
  protected function getPostsPager(sfWebRequest $request, Doctrine_Query $query = null)
  {
    if (!$query)
    {
      $query = Doctrine_Core::getTable('BlogPost')->getPublishedPostsQuery(
        $this->getUser()->getCulture()
      );
    }

    $pager = new sfDoctrinePager('BlogPost', $request->getParameter('limit', sfConfig::get('app_posts_max_per_page', 5)));
    $pager->setQuery($query);
    $pager->setPage($request->getParameter('page', 1));
    $pager->init();
    
    return $pager;
  }
}